import request from "../config/request.js";
import host from "../config/host";

const upload = function(data, success, error) {
  request.defaults({
    method: "post",
    url: host.pcHostUrl + "/wx/file/upload",
    data,
    success,
    error
  });
};

const uploadBase = function(data) {
  return new Promise((resolve, reject) => {
    request.defaults({
      method: "post",
      url: host.pcHostUrl + "/wx/file/upload",
      data,
      success: res => {
        resolve(res);
      },
      error: () => {
        reject(null);
      }
    });
  });
};

export default {
  upload,
  uploadBase
};
